const express = require('express')
const Mock = require('mockjs')
const router = express.Router()

const departments = ['内科', '外科', '五官科', '儿科', '消化内科', '骨科', '康复科']

// 获取科室信息
router.get('/:id?', (req, res) => {
  const { id } = req.params

  if (id) {
    res.json({
      code: 200,
      data: Mock.mock({
        id,
        'name': departments[(id - 1) % departments.length]
      })
    })
  } else {
    res.json({
      code: 200,
      data: Mock.mock({
        'list|7': [{
          'id|+1': 1,
          'name|+1': departments
        }]
      })
    })
  }
})

module.exports = router
